/* 首页 */
// 轮播图js
var swiper = new Swiper(".mySwiper", {
    spaceBetween: 30,
    centeredSlides: true,
    autoplay: {
        delay: 2000,
        disableOnInteraction: false,
    },
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },
    navigation: {
        nextEl: ".swiper-button-next",
        prevEl: ".swiper-button-prev",
    },
});

let cases = document.querySelectorAll(".case")
let imgs = document.querySelectorAll("a img")
cases.forEach(function(item, index) {
    // 移入事件
    item.addEventListener("mouseenter", function() {
        // console.log(this);
        // 移入时背景色变换
        this.style.backgroundColor = "#06f"
            // 移入时改变图片路径
            // 规定i：图片位置和索引对应
        i = index + 1
            // 判断索引是否超过十
        i = i < 10 ? "0" + i : i
            // 改变图片路径
        imgs[index].src = `./images/api${i}-c.svg`
    })
})

cases.forEach(function(item, index) {
    // 移出事件
    item.addEventListener("mouseleave", function() {
        // console.log(this);
        // 移入时背景色变换
        this.style.backgroundColor = "#fff"
            // 移入时改变图片路径
            // 规定i：图片位置和索引对应
        i = index + 1
            // 判断索引是否为10
        i = i < 10 ? "0" + i : i
            // 改变图片路径
        imgs[index].src = `./images/api${i}.svg`

    })
})

let pictures = document.querySelectorAll(".threeimg")
let pars = document.querySelectorAll(".text")
let timer = null
let index = 0

timer = setInterval(function() {
    pictures[index].classList.remove("light")
    pars[index].classList.remove("birth")
    index++
    if (index === 3) {
        index = 0
    }
    pictures[index].classList.add("light")
    pars[index].classList.add("birth")
}, 2000)


console.log(location);
let uname = location.search.substr(11)
    // console.log(uname);
let btn = document.querySelector(".box .btn")
btn.textContent = uname